#include <iostream>
#include "Coin.h"
#include "Product.h"

using namespace std;
using namespace Homework;

namespace Homework
{
Coin::Coin()
{
	payment = 0;
	payment2 = 0;
	//cout << "Please insert amount" << endl;
	//cin >> payment;

	//Check(choice);

}

Coin::~Coin()
{
}

bool Coin::Check(int amount)
{
	do
	{	//cin.ignore();
		//cin.clear();
		
		cout << "Please insert amount" << endl;
		cin >> payment2;

		if(payment2 <= 0)
		{
			cout << "Not an actual amount of money. Please try again" << endl;
			//cin.ignore();
			//cin.clear();
		}
	}while(payment2 <= 0);


	payment = payment + payment2;

	if(food[(Homework::PType)(amount-1)].price == payment)
	{
		return true;
	}
	else if(payment > food[(Homework::PType)(amount-1)].price)
	{
		cout << "Your change is " << (payment-food[(Homework::PType)(amount-1)].price) << endl;
		return true;
	}
	else
	{
		return false;
	}
}

double Coin::getPayment(int amount) {
	return food[(Homework::PType)(amount-1)].price - payment;
}
}